export class CanvasTditor {
  canvas!: HTMLCanvasElement;
  canstructor(width: number = 512, height: number = 512, BgColor: string = '#ffffff') {
    this.canvas = document.createElement("canvas");
    this.canvas.width = width;
    this.canvas.height = height;
    this.canvas.style.backgroundColor = BgColor;
  }
  draw(fun: (ctx: CanvasRenderingContext2D) => void):this {
    const ctx = this.canvas.getContext("2d");
    if (ctx) {
      fun(ctx);
      return this;
    } else {
      console.warn("canvas不支持");
      return this;
    }
  }
}
